package com.dream.mqpushclient.netty;

import com.alibaba.fastjson.JSON;
import com.dream.mqpushserver.common.RpcResult;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

public class NettyClientHandler2 extends SimpleChannelInboundHandler<RpcResult> {

    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        System.out.println("the link is connected " + ctx.channel().remoteAddress());
    }

    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, RpcResult rpcResult) throws Exception {
        System.out.println("this is server response ... \n "+ JSON.toJSONString(rpcResult));
        channelHandlerContext.channel().close();
    }
}
